﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Wicture.DbRESTFul;

namespace Wicture.EPC.OnlineQueryProxy.Core
{
    public class AppConfig
    {
        public static double EsRequestTimeout
        {
            get { return Convert.ToDouble(ConfigurationManager.Settings.Variables["EsRequestTimeout"]); }
        }
        public static string ESUserName
        {
            get { return ConfigurationManager.Settings.Variables["ESUserName"]; }
        }
        public static string ESPwd
        {
            get { return ConfigurationManager.Settings.Variables["ESPwd"]; }
        }
        public static bool EsKeepAliveEnable
        {
            get
            {
                bool ret = false;
                try
                {
                    ret = Convert.ToBoolean(ConfigurationManager.Settings.Variables["EsKeepAliveEnable"]);
                }
                catch { }
                return ret;
            }
        }

        public static int EsKeepAliveTime
        {
            get
            {
                return Convert.ToInt32(ConfigurationManager.Settings.Variables["EsKeepAliveTime"]);
            }
        }

        public static int EsKeepAliveInterval
        {
            get
            {
                return Convert.ToInt32(ConfigurationManager.Settings.Variables["EsKeepAliveInterval"]);
            }
        }

        public static string EsConnectionPool
        {
            get
            {
                return ConfigurationManager.Settings.Variables["EsConnectionPool"];
            }
        }

        /// <summary>
        /// EsClientURL
        /// </summary>
        public static string EsClientURL
        {
            get { return ConfigurationManager.Settings.Variables["EsClientURL"]; }
        }

        public static string PartIndex
        {
            get { return ConfigurationManager.Settings.Variables["PartIndex"]; }
        }

        public static decimal TaxRate
        {
            get
            {
                decimal taxRate = 1.13m;
                try
                {
                    taxRate = Convert.ToDecimal(ConfigurationManager.Settings.Variables["TaxRate"]);
                }
                catch (Exception ex)
                {
                    LoggerManager.Logger.LogError(ex, "AppConfig.TaxRate");
                }
                return taxRate;
            }
        }
    }
}
